Skip to content

feat: webp native (pure-go) implementation#2143

Open
skrashevich wants to merge 6 commits intoAlexxIT:masterfrom
skrashevich:go-webp
Open

feat: webp native (pure-go) implementation#2143
skrashevich wants to merge 6 commits intoAlexxIT:masterfrom
skrashevich:go-webp

Conversation

@skrashevich
Copy link
Copy Markdown
Collaborator

@skrashevich skrashevich commented Mar 10, 2026

This pull request adds native WebP snapshot and streaming support to the project, enabling both single-frame (/api/frame.webp) and multipart streaming (/api/stream.webp) endpoints for WebP images. The implementation uses pure Go (via the (go-webp library), allowing for efficient, dependency-free WebP encoding and decoding. The changes include the core WebP API, HTTP handlers, codec conversion utilities, and documentation updates.

Key changes:

WebP API and HTTP Endpoints:

  • Implements a new internal/webp package providing /api/frame.webp (snapshot) and /api/stream.webp (multipart stream) endpoints, including request handling, caching, and transcoding from H264/H265/JPEG to WebP. (internal/webp/webp.go, internal/webp/webp.goR1-R160)
  • Registers the WebP API in main.go and updates OpenAPI documentation and web UI links to reflect the new endpoints. (main.go, [1] [2]; website/api/openapi.yaml, [3] [4]; www/links.html, [5]

WebP Codec Support and Conversion Utilities:

  • Adds a new pkg/webp package with helpers for encoding/decoding WebP, converting JPEG and RAW frames to WebP, and handling multipart WebP streaming. (pkg/webp/consumer.go, [1]; pkg/webp/helpers.go, [2]; pkg/webp/rtp.go, [3]; pkg/webp/writer.go, [4]
  • Updates the image producer to detect and convert WebP images to JPEG when necessary, ensuring compatibility with existing pipelines. (pkg/image/producer.go, [1] [2] [3] [4]

Dependency and Schema Updates:

  • Adds the go-webp library as an indirect dependency for pure Go WebP support and updates the Go version requirement. (go.mod, [1] [2]
  • Updates the configuration schema to include WebP options and logging. (www/schema.json, [1] [2]

Testing:

  • Introduces comprehensive tests for WebP encoding/decoding and the new API initialization. (internal/webp/webp_test.go, [1]; pkg/webp/webp_test.go, [2]

These changes collectively provide efficient, modern image streaming capabilities with broad browser support and no external dependencies for WebP processing.

========================================
  Binary Size Comparison Tool
========================================

Current branch: go-webp

Building master branch...
Building go-webp branch...

========================================
  Results
========================================

  Branch                        Size   Size (MB)
  ---------------------------------------------------
  master                    18791890    17.92 MB
  go-webp                   19044098    18.16 MB

  ---------------------------------------------------
  Difference:           +246.2 KB (+1.34%)
                       (≈ +0.24 MB)

✓ Binary size change is minimal

- add CLAUDE.md to the ignored files for better cleanliness
- implement WebP streaming with multipart support
- add snapshot endpoint for WebP format with quality options
- introduce WebP encoding using pure Go library without FFmpeg
- update documentation and links for new WebP features
…e/go-astits and github.com/asticode/go-astikit from go.mod and go.sum to clean up unused imports - update the project dependencies for better maintainability
@skrashevich skrashevich self-assigned this Mar 11, 2026
@skrashevich skrashevich added the wontfix This will not be worked on label Mar 11, 2026
@skrashevich skrashevich removed their assignment Mar 11, 2026
@skrashevich skrashevich removed the wontfix This will not be worked on label Mar 11, 2026
@skrashevich skrashevich added this to the dev milestone Mar 15, 2026
@skrashevich skrashevich requested a review from AlexxIT March 22, 2026 22:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant